/*右上角消息小红点*/
import 'package:flutter/material.dart';
import 'package:badges/badges.dart';

class RedDotView extends StatelessWidget {
  late double redNum;
  late double fontSize;
  late Widget mWidget;
  late Color mColor;
  RedDotView({
    required this.redNum,
    this.fontSize=15,
    required this.mWidget,
    this.mColor=const Color(0xFFffffff)});

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Badge(
        position: BadgePosition.topEnd(top: -10, end: -7),
        padding: EdgeInsets.all(6),
        //小红点内内容
        badgeContent: redNum != 0
            ? Text(
                '${redNum}',
                style: TextStyle(
                    fontSize: fontSize, color: mColor),
              )
            : null,
        //小红点颜色
        badgeColor: redNum != 0 ? mColor : Color(0x00000000),
        elevation: 0,
        //true时刷新时会在右则摆动一下
        // showBadge: false,
        child: mWidget,
      ),
    );
  }

}
